_realname=qcma
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=v0.4.0.1.g0791559
pkgrel=2
pkgdesc="Content Manager Assistant for the PS Vita"
arch=(any)
url="https://github.com/codestation/qcma"
license=("GPL")
makedepends=(${MINGW_PACKAGE_PREFIX}-pkg-config)
depends=(${MINGW_PACKAGE_PREFIX}-crt ${MINGW_PACKAGE_PREFIX}-qt5 ${MINGW_PACKAGE_PREFIX}-ffmpeg ${MINGW_PACKAGE_PREFIX}-vitamtp)
options=(strip staticlibs)
source=('git+https://github.com/codestation/qcma.git#branch=testing')
sha256sums=('SKIP')

pkgver() {
  cd qcma
  echo "$(git describe --long --tags | tr - .)"
}

build() {
  unset LDFLAGS

  for opt in gui console; do
    [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}_${opt}
    mkdir -p ${srcdir}/build-${MINGW_CHOST}_${opt} && cd ${srcdir}/build-${MINGW_CHOST}_${opt}
    lrelease ../qcma/qcma.pro
    qmake ../qcma/qcma.pro CONFIG+=${opt} CONFIG+=release
    make
  done
}

package() {

  for opt in gui console; do
    cd ${srcdir}/build-${MINGW_CHOST}_${opt}
    if [ $opt == "console" ]; then
      install -D gui/qcma.exe "${pkgdir}${MINGW_PREFIX}/bin/qcma_console.exe"
    else
      install -D gui/qcma.exe "${pkgdir}${MINGW_PREFIX}/bin/qcma.exe"
    fi
  done
}
